package com.zxw.controller;

import com.aaa.entity.GGoods;
import com.aaa.vo.GoodsVo;
import com.aaa.vo.Result;
import com.zxw.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：zxw
 * @date ：Created in 2023/2/27 12:03
 */
@RestController
@RequestMapping("/goods")
@SuppressWarnings("all")
public class GGoodsController {
    @Autowired
    private GGoodsService goodsService;

    @Autowired
    private BBusinessInfoService businessInfoService;

    @Autowired
    private GSortService gSortService;

    @Autowired
    private GBrandService gBrandService;

    @Autowired
    private GDepositService gDepositService;

    //连表分页查询所有商品
    @RequestMapping("/goods/findAllGoods")
    public Result findAllGoods(@RequestBody GoodsVo goodsVo,
                               @RequestParam(defaultValue = "1") Integer pageCurrent,
                               @RequestParam(defaultValue = "5") Integer pageSize) {
        Result allGoods = goodsService.findAllGoods(goodsVo, pageCurrent, pageSize);
        return allGoods;
    }
    //商品审核
    @RequestMapping("/goods/update")
    public Result update(@RequestBody GGoods goods){
        return goodsService.updateGoods(goods);
    }

    //商品店铺下拉
    @RequestMapping("/findAllShop")
    public Result selectShop(){
        return businessInfoService.findAllBusinessInfo();
    }

    //商品类型下拉
    @RequestMapping("/findAllSort")
    public Result findAllSort(){
        return gSortService.findAllSort();
    }

    //品牌名称下拉
    @RequestMapping("/findAllBrand")
    public Result findAllBrand() {
        return gBrandService.findAllBrand();
    }

    //储藏方式下拉
    @RequestMapping("/findAllDeposit")
    public Result findAllDeposit(){
        return gDepositService.findAllDeposit();
    }

//    @RequestMapping("/findGoodsAndNumByBid/{bid}")
//    public Result findGoodsAndNumByBid(@PathVariable String bid){
//        Result goodsAndNumByBid = goodsService.findGoodsAndNumByBid(bid);
//        System.out.println("goodsAndNumByBid = " + goodsAndNumByBid);
//
//        return goodsAndNumByBid;
//    }
}
